package com.dlsy.ygj.dao.vindicateData.impl;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import net.taobaoge.common.framework.dao.impl.BaseDAOImpl;

import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateCallback;

import com.dlsy.ygj.dao.vindicateData.IMainItemInfoDAO;
import com.dlsy.ygj.entity.MainItemInfo;

public class MainItemInfoDAO extends BaseDAOImpl<MainItemInfo> implements IMainItemInfoDAO{
	
	@SuppressWarnings("unchecked")
	public List<MainItemInfo> findMainItemsById(final Collection<Integer> condtion) {
		
		 return getHibernateTemplate().executeFind(new HibernateCallback() {
			
			public List<MainItemInfo> doInHibernate(Session session) throws HibernateException,
					SQLException {
				Query query=session.createQuery("From MainItemInfo m Where m.mainItemId in (:condtion)");
				query.setParameterList("condtion", condtion);
				List<MainItemInfo> items=query.list();
				if(items !=null && items.size()>0){
					return items;
				}
				return null;
			}
		});
	}

}
